import request from "@/utils/request";
import type { Address } from "@/types/address";
import type { ResponseType } from "@/types/response";

enum Enum {
    address = "/member/address",
}

/*获取收货地址的接口*/
export const fetchAddressAPI = (): Promise<ResponseType<Address[]>> => request.get<Address, ResponseType<Address[]>>(Enum.address);

/*添加收货地址的接口*/
export const addAddressAPI = (data: Address): Promise<ResponseType<{ id: string }>> => request.post<{ id: string }, ResponseType<{ id: string }>>(Enum.address, data);

/*删除收货地址的接口*/
export const deleteAddressAPI = (id: string): Promise<ResponseType<{ id: string }>> => request.delete<{ id: string }, ResponseType<{ id: string }>>(`${Enum.address}/${id}`);

/*查找收货地址详情的接口*/
export const findAddressAPI = (id: string): Promise<ResponseType<Address>> => request.get<Address, ResponseType<Address>>(`${Enum.address}/${id}`);

/*修改收货地址的接口*/
export const editAddressAPI = (data: Address): Promise<ResponseType<Address>> => request.put<Address, ResponseType<Address>>(`${Enum.address}/${data.id}`,data);


